package satir.command;

import java.util.Scanner;

import satir.SatirGame;

/**
 * The Class EnterPlayerNameCmd.
 * 
 * @version 2.0 March 2012
 * @author Bill Chan
 */
public class EnterPlayerNameCmd implements Command {
	
	/** The satir game. */
	private SatirGame satirGame;
	/** The index. */
	private int index = 1;

	/**
	 * Instantiates a new enter player name cmd.
	 *
	 * @param satirGame the satir game
	 */
	public EnterPlayerNameCmd(SatirGame satirGame) {
		this.satirGame = satirGame;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see stair.command.PlayerCmd#execute()
	 */
	public void execute() {
		String playerName;
		Scanner scanner = new Scanner(System.in);
		for (int i = 0; i < satirGame.getNumOfPlayer(); i++) {
			System.out.println("Player " + index + " please input your name:");
			playerName = scanner.next(); // get the player name from input
			System.out.println("Hi [" + playerName + "]");
			satirGame.getPlayers(i).setName(playerName);
			index++;
		}
	}

}